﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Lecturers/Lecturers.Master"
    Inherits="System.Web.Mvc.ViewPage<CollaborationRoom>" %>
<%@ Import Namespace="ViewRes" %>

<asp:Content ID="ScriptsContent" ContentPlaceHolderID="ScriptsContent" runat="server">
    <script src="<%:Url.Content("~/Scripts/Diploma.js")%>" type="text/javascript"> </script>
    <script src="<%:Url.Content("~/Scripts/Diploma.DialogHelper.js")%>" type="text/javascript"> </script>
    <script type="text/javascript">
        $(function() {
            $("#CollaborationRoomId").clone().appendTo("form");
            $("#StartDate").focusout(function() {
                if ($("#StartDate").val() == "")
                    return false;
                $("#PrevCheckPointId").show();
            });
            loadPlaningsControl();
        });

        function loadPlaningsControl() {
            var path = '<%:Url.RouteUrl("Default", new {  controller = "TimeLine",  action = "LoadPlaningsControl", roomId = Model.CollaborationRoomId  })%>';

            $("#planings").load(path, function() {

            });
        }

        function loadTasksByRoomAndPlaning(planingsSelectId, taskDate, tasksSelectId) {
            if ($("#StartDate").val() == "") {
                alert("<%:LecturerStrings.EnterDate%>");
                return false;
            }
            $("#PrevCheckPointId").show();
            var roomId = $("#CollaborationRoomId").val();
            var selectedPlaningValue = $("#" + planingsSelectId + " option:selected").val();
            if (selectedPlaningValue == "")
                return false;
            var link = '<%:Url.RouteUrl("Default", new {controller = "Tasks", action = "ByRoomAndPlaningJSON"})%>' + '?roomId=' + roomId + '&planingId=' + selectedPlaningValue;
            if (taskDate != "")
                link += '&taskDate=' + taskDate;
            $.getJSON(link, function(data) {
                $("#" + tasksSelectId).empty();
                $("#" + tasksSelectId).append("<option class='disabled'><%:LecturerStrings.Previous%></option>");
                $(data).each(function() {
                    $("#" + tasksSelectId).append("<option value='" + this.id + "'>" + this.name + "</option>");
                });
            });
        }

        function addTask() {

            openDialog('<%:Url.RouteUrl("Default", new {controller = "Tasks", action = "Add"})%>', '<%:LecturerStrings.AddTask%>', function() {
                var datePickerScriptFilePath = '<%:Url.Content("~/Scripts/")%>' + 'ui.datepicker-' + '<%=ViewData["LocalLanguage"]%>' + '.js';
                $.ajax({
                        url: datePickerScriptFilePath,
                        dataType: 'script',
                        async: false,
                        success: function(data) {
                            $("#StartDate").datepicker($.datepicker.regional['<%=ViewData["LocalLanguage"]%>']);
                            $("#divDialog form").attr("onSuccess", "loadPlaningsControl();");
                        }
                    });
            });
        }
         function editGlobalTaskStatus(link) {

            openDialog(link, 'Изменить статус контрольной точки', function() {
                var datePickerScriptFilePath = '<%:Url.Content("~/Scripts/")%>' + 'ui.datepicker-' + '<%=ViewData["LocalLanguage"]%>' + '.js';
                $.ajax({
                        url: datePickerScriptFilePath,
                        dataType: 'script',
                        async: false,
                        success: function() {
                            $.datepicker.setDefaults($.datepicker.regional['']);
                            $("#StartDate").datepicker($.datepicker.regional['<%=ViewData["LocalLanguage"]%>']);
                            $("#divDialog form").attr("onSuccess", "loadPlaningsControl();");
                            }
                    });
            });
        }

        function editTask(link) {

            openDialog(link, '<%:LecturerStrings.EditTask%>', function() {
                var datePickerScriptFilePath = '<%:Url.Content("~/Scripts/")%>' + 'ui.datepicker-' + '<%=ViewData["LocalLanguage"]%>' + '.js';
                $.ajax({
                        url: datePickerScriptFilePath,
                        dataType: 'script',
                        async: false,
                        success: function() {
                            $.datepicker.setDefaults($.datepicker.regional['']);
                            $("#StartDate").datepicker($.datepicker.regional['<%=ViewData["LocalLanguage"]%>']);
                            $("#divDialog form").attr("onSuccess", "loadPlaningsControl();");
                        }
                    });
            });
        }

        function taskDeleted() {
            $("div").RemoveBubblePopup();
            loadPlaningsControl();
        }
        
    </script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%:SharedStrings.CollaborationRoom%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%
        Html.RenderPartial("~/Views/CollaborationRooms/CollaborationRoomHeader.ascx", Model);%>
    <br />
    <div>
        <div></div>
        <div class="smalltitle">Работа с сообщениями </div>
        <img class="sticker" src="<%:Url.Content("~/Content/Icons/creattica-icon.png")%>" />
        <div id="left">
            <%
        Html.RenderPartial("~/Views/Messages/ChatControl.ascx", Model, ViewData);%>
        </div>
    </div>
    <hr />
    <div>
        <div class="smalltitle">Работа с контрольными точками </div>
        <img class="sticker" src="<%:Url.Content("~/Content/Icons/rockable-press-icon.png")%>" />
        <div class="addlink">
            <a href="javascript:void(0)" onclick=" addTask(); ">
                <%:SharedStrings.Add%></a></div>
        <div id="planings">
        </div>
    </div>
    <hr />
    <div>
        <div class="smalltitle">Работа с файлами</div>
        <img class="sticker" src="<%:Url.Content("~/Content/Icons/envato-icon.png")%>" />
        <div align="center">
            <img src="<%:Url.Content("~/Content/Icons/Green-Leaf-Logo.png")%>" style="width: 200px;" />
            <iframe src="<%:Url.RouteUrl("FileManager",
                                           new
                                               {
                                                   roomId = Model.CollaborationRoomId,
                                                   userId = ((User) ViewData["LoggedUser"]).UserId
                                               })%>"
                id="FileManager"></iframe>
            <img src="<%:Url.Content("~/Content/Icons/Green-Leaf-Logo.png")%>" style="width: 200px;" />
        </div>
    </div>
</asp:Content>
